package article10.equals;

import java.util.Objects;

/**
 * broken- violates symmetry!
 * 违反对称性
 *
 * @Author: cctv
 * @Date: 2019/4/1 17:09
 */
public final class CaseInsensitiveString {
    private final String s;

    public CaseInsensitiveString(String s) {
        this.s = Objects.requireNonNull(s);
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof CaseInsensitiveString) {
            return s.equalsIgnoreCase(((CaseInsensitiveString) o).s);
        }
        return false;
    }


    public boolean equals1(Object o) {
        return o instanceof CaseInsensitiveString &&((CaseInsensitiveString) o).s.equalsIgnoreCase(s);
    }

    //remainder omitted
}
